\defmodule {YListSeriesCollection}

This class extends
\externalclass{umontreal.iro.lecuyer.charts}{XYListSeriesCollection}.
The data is given as lists of $y$-coordinates. The $x$-coordinates are
regularly spaced multiples of the indices of the data points.

\bigskip\hrule
\begin{code}
\begin{hide}
/*
 * Class:        YListSeriesCollection
 * Description:  Lists of y-coordinates of charts
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.charts;\begin{hide}

import   org.jfree.data.xy.XYSeries;
import   org.jfree.data.xy.XYSeriesCollection;
import   org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
\end{hide}

public class YListSeriesCollection extends XYListSeriesCollection \begin{hide} {

   private void initYListSeries (double h, double[] data, int numPoints)
   {
      renderer = new XYLineAndShapeRenderer(true, false);
      seriesCollection = new XYSeriesCollection();

      XYSeriesCollection tempSeriesCollection =
         (XYSeriesCollection)seriesCollection;
      XYSeries serie = new XYSeries(" ");
      for (int j = 0; j < numPoints; j++)
         serie.add(h*(j+1), data[j]);
      tempSeriesCollection.addSeries(serie);

      // set default colors
      renderer.setSeriesPaint(0, getDefaultColor(0));

      // set default plot style
      plotStyle = new String[1];
      marksType = new String[1];
      dashPattern = new String[1];
      marksType[0] = " ";
      plotStyle[0] = "smooth";
      dashPattern[0] = "solid";
   }


   private void initYListSeries (boolean flag, double[]... data)
   {
      // if flag = true, h = 1; else h = 1/numPoints
      double h;
      renderer = new XYLineAndShapeRenderer(true, false);
      seriesCollection = new XYSeriesCollection();

      XYSeriesCollection tempSeriesCollection =
         (XYSeriesCollection)seriesCollection;
      for (int i = 0; i < data.length; i ++) {
         XYSeries serie = new XYSeries(" ");
         if (flag)
            h = 1;
         else
            h = 1.0 / data[i].length;
         for (int j = 0; j < data[i].length; j++)
            serie.add(h*(j+1), data[i][j]);
         tempSeriesCollection.addSeries(serie);
      }

      final int s = tempSeriesCollection.getSeriesCount();

      // set default colors
      for(int i = 0; i < s; i++) {
         renderer.setSeriesPaint(i, getDefaultColor(i));
      }

      // set default plot style
      plotStyle = new String[s];
      marksType = new String[s];
      dashPattern = new String[s];
      for (int i = 0; i < s; i++) {
         marksType[i] = " ";
         plotStyle[i] = "smooth";
         dashPattern[i] = "solid";
      }
   //   dashPattern[s-1] = "dashed";     // for the line y = x
   }\end{hide}
\end{code}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Constructors}

\begin{code}

   public YListSeriesCollection (double[]... data) \begin{hide} {
      initYListSeries (true, data);
   }\end{hide}
\end{code}
\begin{tabb}
   Creates a new \texttt{YListSeriesCollection} instance with default
   parameters and given data series. The input vectors represent sets of
   plotting data. More specifically, each vector \texttt{data} represents
   a $y$-coordinates set.
   Position in the vector will form the $x$-coordinates. Indeed the value
   \texttt{data}$[j]$ corresponds to the point
   $(j+1, \mbox{\texttt{data}}[j])$ on the chart.
\end{tabb}
\begin{htmlonly}
   \param{data}{series of point sets.}
\end{htmlonly}
\begin{code}

   public YListSeriesCollection (boolean flag, double[]... data) \begin{hide} {
      initYListSeries (flag, data);
   }\end{hide}
\end{code}
\begin{tabb}
  Similar to the constructor %
  \latex{\method{YListSeriesCollection}{double[]}\texttt{(data)}} %
  above, except that if \texttt{flag} is \texttt{true}, the points are
 $(j+1, \mbox{\texttt{data}}[j])$ for each series;
  but if \texttt{flag} is \texttt{false},
  the points are $((j+1)/n, \mbox{\texttt{data}}[j])$, where $n$ is
  the number of points of each series in \texttt{data}.
\end{tabb}
\begin{htmlonly}
   \param{flag}{to choose the step between $x$-coordinates}
   \param{data}{series of point sets.}
\end{htmlonly}
\begin{code}

   public YListSeriesCollection (double[] data, int numPoints) \begin{hide} {
      initYListSeries (1, data, numPoints);
   }\end{hide}
\end{code}
\begin{tabb}
   Creates a new \texttt{YListSeriesCollection} instance with default
   parameters and one data series.
   The vector \texttt{data} represents the $y$-coordinate of the points,
   and position in the vector represents the $x$-coordinate.
  However, only \emph{the first} \texttt{numPoints} of \texttt{data} will
  be considered in the series.
  Thus the coordinates of the points are given by
   $(j,\ \mbox{\texttt{data}}[j-1])$,
    for $j=1,2,\ldots, \texttt{numPoints}$.
\end{tabb}
\begin{htmlonly}
   \param{data}{point set.}
   \param{numPoints}{Number of points to plot}
\end{htmlonly}
\begin{code}

   public YListSeriesCollection (double h, double[] data, int numPoints) \begin{hide} {
      initYListSeries (h, data, numPoints);
   }\end{hide}
\end{code}
\begin{tabb}
  Similar to the constructor %
  \method{YListSeriesCollection}{double[],int}\texttt{(data, numPoints)} %
  above,  but the points are $(hj,\ \mbox{\texttt{data}}[j-1])$,
    for $j=1,2,\ldots, \texttt{numPoints}$.
\end{tabb}
\begin{htmlonly}
   \param{h}{step between $x$-coordinates}
   \param{data}{point set.}
   \param{numPoints}{Number of points to plot}
\end{htmlonly}
\begin{code}

   public YListSeriesCollection (double[][] data, int numPoints) \begin{hide} {
      renderer = new XYLineAndShapeRenderer(true, false);
      seriesCollection = new XYSeriesCollection();

      XYSeriesCollection tempSeriesCollection =
         (XYSeriesCollection)seriesCollection;
      for (int i = 0; i < data.length; i ++) {
         XYSeries serie = new XYSeries(" ");
         for (int j = 0; j < numPoints; j++)
            serie.add(j + 1, data[i][j]);
         tempSeriesCollection.addSeries(serie);
      }

      final int s = tempSeriesCollection.getSeriesCount();

      // set default colors
      for (int i = 0; i < s; i++) {
         renderer.setSeriesPaint(i, getDefaultColor(i));
      }

      // set default plot style
      plotStyle = new String[s];
      marksType = new String[s];
      dashPattern = new String[s];
      for (int i = 0; i < s; i++) {
         marksType[i] = " ";
         plotStyle[i] = "smooth";
         dashPattern[i] = "solid";
      }
   }
}\end{hide}
\end{code}
\begin{tabb}
   Creates a new \texttt{YListSeriesCollection} instance with default
   parameters and given data series. The matrix \texttt{data} represents a
   set of plotting data. More specifically, each row of \texttt{data}
   represents a $y$-coordinates set.
   Position in the vector will form the $x$-coordinates. Indeed, for each serie
   $i$, the value \texttt{data}$[i][j]$ corresponds to the point
   $(j+1, \mbox{\texttt{data}}[j])$ on the chart.
  However, only \emph{the first} \texttt{numPoints} of \texttt{data} will
  be considered for each series of points.
\end{tabb}
\begin{htmlonly}
   \param{data}{series of point sets.}
   \param{numPoints}{Number of points to plot}
\end{htmlonly}
